Optimal. Leaf size=100 \[ \frac{2 (a A-b B) \tan ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{1}{2} (c+d x)\right )}{\sqrt{a+b}}\right )}{d (a-b)^{3/2} (a+b)^{3/2}}-\frac{(A b-a B) \sin (c+d x)}{d \left (a^2-b^2\right ) (a+b \cos (c+d x))} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.0885387, antiderivative size = 100, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 4, integrand size = 23, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.174, Rules used = {2754, 12, 2659, 205} \[ \frac{2 (a A-b B) \tan ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{1}{2} (c+d x)\right )}{\sqrt{a+b}}\right )}{d (a-b)^{3/2} (a+b)^{3/2}}-\frac{(A b-a B) \sin (c+d x)}{d \left (a^2-b^2\right ) (a+b \cos (c+d x))} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 2754
Rule 12
Rule 2659
Rule 205
Rubi steps
\begin{align*} \int \frac{A+B \cos (c+d x)}{(a+b \cos (c+d x))^2} \, dx &=-\frac{(A b-a B) \sin (c+d x)}{\left (a^2-b^2\right ) d (a+b \cos (c+d x))}+\frac{\int \frac{-a A+b B}{a+b \cos (c+d x)} \, dx}{-a^2+b^2}\\ &=-\frac{(A b-a B) \sin (c+d x)}{\left (a^2-b^2\right ) d (a+b \cos (c+d x))}+\frac{(a A-b B) \int \frac{1}{a+b \cos (c+d x)} \, dx}{a^2-b^2}\\ &=-\frac{(A b-a B) \sin (c+d x)}{\left (a^2-b^2\right ) d (a+b \cos (c+d x))}+\frac{(2 (a A-b B)) \operatorname{Subst}\left (\int \frac{1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac{1}{2} (c+d x)\right )\right )}{\left (a^2-b^2\right ) d}\\ &=\frac{2 (a A-b B) \tan ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{1}{2} (c+d x)\right )}{\sqrt{a+b}}\right )}{(a-b)^{3/2} (a+b)^{3/2} d}-\frac{(A b-a B) \sin (c+d x)}{\left (a^2-b^2\right ) d (a+b \cos (c+d x))}\\ \end{align*}
Mathematica [A] time = 0.317253, size = 97, normalized size = 0.97 \[ \frac{\frac{2 (a A-b B) \tanh ^{-1}\left (\frac{(a-b) \tan \left (\frac{1}{2} (c+d x)\right )}{\sqrt{b^2-a^2}}\right )}{\left (b^2-a^2\right )^{3/2}}+\frac{(a B-A b) \sin (c+d x)}{(a-b) (a+b) (a+b \cos (c+d x))}}{d} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [B] time = 0.103, size = 234, normalized size = 2.3 \begin{align*} -2\,{\frac{A\tan \left ( 1/2\,dx+c/2 \right ) b}{d \left ({a}^{2}-{b}^{2} \right ) \left ( \left ( \tan \left ( 1/2\,dx+c/2 \right ) \right ) ^{2}a- \left ( \tan \left ( 1/2\,dx+c/2 \right ) \right ) ^{2}b+a+b \right ) }}+2\,{\frac{a\tan \left ( 1/2\,dx+c/2 \right ) B}{d \left ({a}^{2}-{b}^{2} \right ) \left ( \left ( \tan \left ( 1/2\,dx+c/2 \right ) \right ) ^{2}a- \left ( \tan \left ( 1/2\,dx+c/2 \right ) \right ) ^{2}b+a+b \right ) }}+2\,{\frac{aA}{d \left ( a-b \right ) \left ( a+b \right ) \sqrt{ \left ( a-b \right ) \left ( a+b \right ) }}\arctan \left ({\frac{\tan \left ( 1/2\,dx+c/2 \right ) \left ( a-b \right ) }{\sqrt{ \left ( a-b \right ) \left ( a+b \right ) }}} \right ) }-2\,{\frac{Bb}{d \left ( a-b \right ) \left ( a+b \right ) \sqrt{ \left ( a-b \right ) \left ( a+b \right ) }}\arctan \left ({\frac{\tan \left ( 1/2\,dx+c/2 \right ) \left ( a-b \right ) }{\sqrt{ \left ( a-b \right ) \left ( a+b \right ) }}} \right ) } \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A] time = 1.28773, size = 846, normalized size = 8.46 \begin{align*} \left [-\frac{{\left (A a^{2} - B a b +{\left (A a b - B b^{2}\right )} \cos \left (d x + c\right )\right )} \sqrt{-a^{2} + b^{2}} \log \left (\frac{2 \, a b \cos \left (d x + c\right ) +{\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + 2 \, \sqrt{-a^{2} + b^{2}}{\left (a \cos \left (d x + c\right ) + b\right )} \sin \left (d x + c\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + a^{2}}\right ) - 2 \,{\left (B a^{3} - A a^{2} b - B a b^{2} + A b^{3}\right )} \sin \left (d x + c\right )}{2 \,{\left ({\left (a^{4} b - 2 \, a^{2} b^{3} + b^{5}\right )} d \cos \left (d x + c\right ) +{\left (a^{5} - 2 \, a^{3} b^{2} + a b^{4}\right )} d\right )}}, \frac{{\left (A a^{2} - B a b +{\left (A a b - B b^{2}\right )} \cos \left (d x + c\right )\right )} \sqrt{a^{2} - b^{2}} \arctan \left (-\frac{a \cos \left (d x + c\right ) + b}{\sqrt{a^{2} - b^{2}} \sin \left (d x + c\right )}\right ) +{\left (B a^{3} - A a^{2} b - B a b^{2} + A b^{3}\right )} \sin \left (d x + c\right )}{{\left (a^{4} b - 2 \, a^{2} b^{3} + b^{5}\right )} d \cos \left (d x + c\right ) +{\left (a^{5} - 2 \, a^{3} b^{2} + a b^{4}\right )} d}\right ] \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-1)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A] time = 1.29264, size = 215, normalized size = 2.15 \begin{align*} -\frac{2 \,{\left (\frac{{\left (\pi \left \lfloor \frac{d x + c}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac{a \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right ) - b \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )}{\sqrt{a^{2} - b^{2}}}\right )\right )}{\left (A a - B b\right )}}{{\left (a^{2} - b^{2}\right )}^{\frac{3}{2}}} - \frac{B a \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right ) - A b \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )}{{\left (a \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{2} - b \tan \left (\frac{1}{2} \, d x + \frac{1}{2} \, c\right )^{2} + a + b\right )}{\left (a^{2} - b^{2}\right )}}\right )}}{d} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]